package com.example.system.security.service;

import com.example.common.entity.SysUser;
import com.example.system.security.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.List;

@Service
public class UserService {
    
    private final UserMapper userMapper;
    
    @Autowired
    public UserService(UserMapper userMapper) {
        this.userMapper = userMapper;
    }
    
    /**
     * 根据用户名查询用户信息
     * @param username 用户名
     * @return User实体，找不到返回null
     */
    public SysUser findByUsername(String username) {
        return userMapper.selectByUsername(username);
    }
    
    /**
     * 根据用户ID查询用户权限列表
     * @param userId 用户ID
     * @return 权限字符串列表
     */
    public List<String> getUserPermissions(BigInteger userId) {
        return userMapper.selectPermissionsByUserId(userId);
    }
}
